package com.fit.entities;

import java.util.LinkedList;
import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;

import org.apache.tapestry5.beaneditor.NonVisual;
import org.apache.tapestry5.beaneditor.Validate;

import com.fit.entities.manytomany.UserOrgan;

@Entity
@Table(name="Organization")
public class Organization {
	@Id
	@GeneratedValue(strategy = GenerationType.IDENTITY)
	@NonVisual
	@Column(name = "id")
	private long id;
	@Validate("required")
	@Column(name="name", nullable=false)
	private String name;
	@Validate("required")
	@Column(name="adress", nullable=false)
	private String adress;
	@Validate("required")
	@Column(name="phone", nullable=false)
	private String phone;
	@Validate("required")
	@Column(name="webpage", nullable= true)
	private String webpage;
	@Validate("required")
	@Column(name="email", nullable= true)
	private String email;
	@ManyToOne(cascade = CascadeType.ALL, optional = false)
	@JoinColumn(name = "org_contact_person_id")
	private ContactPerson contactPerson;
	@OneToMany(fetch = FetchType.LAZY, mappedBy = "pk.organization")
	private List<UserOrgan> userOrgan = new LinkedList<UserOrgan>();
	
	public long getId() {
		return id;
	}
	public void setId(long id) {
		this.id = id;
	}
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	public String getAdress() {
		return adress;
	}
	public void setAdress(String adress) {
		this.adress = adress;
	}
	public String getPhone() {
		return phone;
	}
	public void setPhone(String phone) {
		this.phone = phone;
	}
	public String getWebpage() {
		return webpage;
	}
	public void setWebpage(String webpage) {
		this.webpage = webpage;
	}
	public String getEmail() {
		return email;
	}
	public void setEmail(String email) {
		this.email = email;
	}
	public ContactPerson getContactPerson() {
		return contactPerson;
	}
	public void setContactPerson(ContactPerson contactPerson) {
		this.contactPerson = contactPerson;
	}
	public List<UserOrgan> getUserOrgan() {
		return userOrgan;
	}
	public void setUserOrgan(List<UserOrgan> userOrgan) {
		this.userOrgan = userOrgan;
	}
	
	
	
	
}
